#ifndef STITCH_H
#define STITCH_H

#include <QObject>
#include <QScopedPointer>

#include "noncopyable.h"
#include "thememgr.h"
#include "global.h"

namespace stitch {
class MainWindow;
class Node;
class TaskMgr;
struct FileOpenParameters;
class Stitch : public QObject, private Noncopyable
{
    Q_OBJECT
public:
    static Stitch &getInst()
    {
        static Stitch inst;
        return inst;
    }
    ThemeMgr &getThemeMgr() const;
    TaskMgr &getTaskMgr() const;
    void setMainWindow(MainWindow *p_mainWindow);
    MainWindow *getMainWindow() const;
public slots:
           void showTips(const QString &p_message, int p_timeoutMilliseconds = 3000);
signals:
         // Requested to open @p_filePath.
    void openFileRequested(const QString &p_filePath, const QSharedPointer<stitch::FileOpenParameters> &p_paras);
    // Requested to show output message.
    void showOutputRequested(const QString &p_text);
    // Requested to show status message.
    void statusMessageRequested(const QString &p_message, int p_timeoutMilliseconds);
    void tipsRequested(const QString &p_message, int p_timeoutMilliseconds);
    // Requested to locate node in explorer.
    void locateNodeRequested(stitch::Node *p_node);

private:
    explicit Stitch(QObject *p_parent = nullptr);
    MainWindow *m_mainWindow;
    // QObject managed.
    ThemeMgr *m_themeMgr;
    // QObject managed.
    TaskMgr *m_taskMgr;
    // Used to identify app's instance.
    ID m_instanceId = 0;

    void initThemeMgr();
    void initTaskMgr();
};
}

#endif // STITCH_H
